package cn.wolfcode.crm.query;

import com.alibaba.druid.util.StringUtils;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Calendar;
import java.util.Date;

@Getter
@Setter
public class SigninQueryObject extends QueryObject {
    private String realname;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date beginDate;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date endDate;

    public String getRealname() {
        return StringUtils.isEmpty(realname) ? null : realname;
    }

    public void setEndDate(Date endDate) {
        if (endDate != null) {

            Calendar cal = Calendar.getInstance();
            cal.setTime(endDate);
            cal.add(Calendar.DATE, 1);
            cal.add(Calendar.SECOND, -1);
            this.endDate = cal.getTime();
        }else {
            this.endDate=endDate;
        }

    }

}
